﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufValueInput.h"
#include "GnufTextControl.h"

namespace gnuf {
    
    class GNUF_BASE_EXPORT TextValueInput 
        : public ValueInput<std::wstring>
        , public ITextControlHandler
    {
        DEFINE_CAST_DERIVED(gnuf::TextValueInput, gnuf::ValueInputBase)
    public:
        explicit TextValueInput(std::uint16_t, const std::wstring &, bool readonly, gcmp::OwnerPtr< Info > &);
        TextValueInput(std::uint16_t, const std::wstring &, bool readonly, gcmp::OwnerPtr< Info > &, const std::wstring& validator);
        virtual ~TextValueInput();

        const TextControl * textControl() const;
        TextControl * textControl();
    
        const std::wstring& validator() const { return m_validator; }

    protected:
        // Inherits from ValueInput...
        virtual void onPostValueChanged() override;
        virtual void onPostAbilityChanged() override;

        // Inherits from ITextControlHandler...
        virtual void onTextChanged(const std::wstring &) override;
        
    private:
        gcmp::OwnerPtr< TextControl > m_textCtrl;
        std::wstring m_validator;
    };

}
